package com.starbucks.opencase.function;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.starbucks.opencase.enums.enumCMKey;
import com.starbucks.opencase.enums.enumCMMark;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class funSend {
    @Autowired
    private funSession funSession;

    /**
     * 发送扣除能量通知
     * @param id
     * @param energy
     * @param expendEnergy
     */
    public void expendEnergy(String id,long energy,long expendEnergy){
        ObjectMapper om=new ObjectMapper();
        ObjectNode on=om.createObjectNode();
        on.put(enumCMKey.mark.name(), enumCMMark.expendEnergy.ordinal());
        on.put(enumCMKey.timestamp.name(), System.currentTimeMillis());
        on.put(enumCMKey.status.name(), true);
        on.put(enumCMKey.expendEnergy.name(), expendEnergy);
        on.put(enumCMKey.energy.name(), energy);
        funSession.sendMessage(id,on);
    }
}
